﻿using Common.Helpers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Collections.Specialized.BitVector32;

namespace GptChatBatch.WinUI.Configs
{
    public class AppConfigIni
    {
        public static string FilePath { get; set; }
        static AppConfigIni() 
        {
            FilePath = Path.Combine(Environment.CurrentDirectory, "CfgFiles/app_config.ini");
            if (!File.Exists(FilePath)) 
            { 
                File.Create(FilePath);
            } 
        }

        public static void WriteValue(string section, string key, string value)
        {
            IniFileHelper iniFile = new IniFileHelper(FilePath);           
            iniFile.WriteValue(section, key, value);          
        }

        public static string ReadValue(string section, string key)
        {
            IniFileHelper iniFile = new IniFileHelper(FilePath);
            //读取配置项：
            string value = iniFile.ReadValue(section, key);
            return value;
        }

        public static Dictionary<string, Dictionary<string, string>> GetDictionary()
        {
            IniFileHelper iniFile = new IniFileHelper(FilePath);
            //读取配置项：
            Dictionary<string, Dictionary<string, string>> dict= iniFile.GetDictionary();
            return dict;
        }


    }
}
